<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of qcm
 *
 * @author didile
 */
class QcmView {
public $tpl;
public $qcmArray; 

   public function __construct() {
        $this->tpl = new Smarty();
        $this->qcmArray = array();
        /** Récupération de la liste des rubriques**/
         $rubriques = Rubrique::getAll();         
         $array_rub = array();     
         
        /** Création d'un tableau associatif pour la liste d'option**/
        foreach($rubriques as $rub){ 
            $array_rub[$rub['id']] = $rub['libelle'];           
        }
              
        
        /**Ajout de la liste d'option au template **/
        $this->tpl->assign("rubriquesOptions",$array_rub);
        $this->tpl->assign("selectRubrique",'select');
         
        /* Récupération des QCM*/              
        foreach ($rubriques as $value) {            
            array_push($this->qcmArray,new Qcm($value['id']));
        }           
        
        $array_qcm = array();
          /** Création d'un tableau associatif pour l'affichage**/
        $i=0;
        foreach($this->qcmArray as $qcm){ 
            $array_qcm[$i]['id'] = $qcm->id;           
            $array_qcm[$i]['nbQuestion'] = $qcm->nbQuestion;   
            $array_qcm[$i]['libelle'] = $qcm->libelle;  
            $i++;
        }
        
        $this->tpl->assign('qcmArray', $array_qcm );
      //url
        $url = URL_PATH;
           $this->tpl->assign('url', $url );
       
   }

   public function __toString() {
       
   }
   
   /** Fonction permettant d'afficher un template**/
   public function display($tpl_name){
       //$this->tpl->loadFilter("pre","form");
        $this->tpl->display($tpl_name);
   }
}

?>
